package org.example.BIO_01;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.ServerSocket;
import java.net.Socket;

// 客户端：连接服务端，发送消息
public class Client {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1",9999);
        System.out.println("客户端启动，连接到"+socket.getInetAddress());
        OutputStream os = socket.getOutputStream();
        PrintStream ps = new PrintStream(os);
        ps.println("hello world");
        ps.flush();
        ps.close();
    }
}
